const mongoose = require('mongoose');
const { getMeta, preSave } = require('../helpers');

/** 定义 Log Schema */
const LogSchema = new mongoose.Schema({
  user: {
    username: String,
    id: String,
  },
  request: {
    method: String,
    url: String,
    body: String,
    status: Number,
  },
  show: Boolean,
  meta: getMeta(),
});

LogSchema.pre('save', preSave);

/** 注册 Log shecma */
mongoose.model('Log', LogSchema);
